<h2 class="contentTitle">表单验证</h2>


<div class="pageContent">
	
	{if $action_name=='addattrg'}
	<form id="myform" method="post" action="{:U($module_name.'/insertg')}" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
	{else}
	<form id="myform" method="post" action="{:U($module_name.'/updateg')}" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
	{if $info['id']}
		<input type="hidden" name="id" value="{$info['id']}" />
	{/if}

	{/if}
		<div class="pageFormContent nowrap" layoutH="97">
			<dl>
				<dt>分类类型：</dt>
				<dd>
					<select name="category_id" >
						<option value="">请选择分类</option>
						<option value="3" {if 3==$info['category_id']}selected='selected'{/if}>手机</option>
						<option value="70" {if 70==$info['category_id']}selected='selected'{/if}>平板</option>
						<option value="4" {if 4==$info['category_id']}selected='selected'{/if}>配件</option>
						<option value="14" {if 14==$info['category_id']}selected='selected'{/if}>饰品</option>
						<option value="186" {if 186==$info['category_id']}selected='selected'{/if}>靓号</option>
					</select>
				</dd>
			</dl>
			<dl>
				<dt>分组名称：</dt>
				<dd>
					<input type="text" name="code" maxlength="20" class="required"  
					 placeholder="请输入属性名称" value="{$info['code']}" style="float: none;" data-validate="validate(required);"/>
				</dd>
			</dl>
				<dl>
				<dt>分组排序：</dt>
				<dd>
					<input type="text" name="sequence" maxlength="20" class="required"  
					 placeholder="0－100以内的数字" value="{$info['sequence']}" style="float: none;" data-validate="validate(required,digits);"/>
				</dd>
			</dl>
		</div>
			<div class="formBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
					<li>
						<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
					</li>
				</ul>
			</div>		
	</form>
	
</div>

<script>
    $(function(){
        $.ketchup.createErrorContainer(function(form, el) {
            return $('<ul/>', {
                    'class': 'ketchup-custom'
                    }).insertAfter(el);
        }).addErrorMessages(function(form, el, container, messages) {
            container.html('');

            for(i = 0; i < messages.length; i++) {
            $('<li/>', {
                text: messages[i]
            }).appendTo(container);
            }
        }).showErrorContainer(function(form, el, container) {
            container.slideDown('fast');
        }).hideErrorContainer(function(form, el, container) {
            container.slideUp('fast');
        });

        $('#myform').ketchup({
            validateEvents: 'blur keyup'
        });    
    })
</script>